<?php

namespace App\Http\Requests;

use App\Http\Services\Admin\CoinsTypeService;
use App\Models\CoinsType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class CoinsCodingCreateRequest extends FormRequest
{
    use CommonRequest;
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'type_code' => [
                'required',
                'alpha',
                Rule::unique((new CoinsType())->getTable(),'type_code')
            ],
            'type_name' => [
                'required',
                Rule::unique((new CoinsType())->getTable(),'type_name')
            ],
        ];
    }

    public function messages()
    {
        return [
            'type_code.required' =>'编码必填项',
            'type_code.alpha' =>'编码只能为字母',
            'type_code.unique' =>'编码已经存在',
            'type_name.required' =>'业务类型必填项',
            'type_name.unique' =>'编码名称已经存在',
        ];
    }
}
